home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 July: Mac OS SDK / Dev.CD Jul 00 SDK2.toast / Development Kits / Cross Platform / QuickTime 4.1.2 Windows SDK / CIncludes / NSL.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-04-12  |  30.3 KB  |  787 lines  |  [TEXT/R*ch]

  1. /*
  2.      File:        NSL.h
  3.  
  4.      Contains:    Interface to API for using the NSL Manager
  5.  
  6.      Version:    Technology:    Mac OS 8.5
  7.                  Release:    QuickTime 4.1
  8.  
  9.      Copyright:    (c) 1985-1999 by Apple Computer, Inc., all rights reserved
  10.  
  11.      Bugs?:        For bug reports, consult the following page on
  12.                  the World Wide Web:
  13.  
  14.                      http://developer.apple.com/bugreporter/
  15.  
  16. */
  17. #ifndef __NSL__
  18. #define __NSL__
  19.  
  20. #ifndef __CODEFRAGMENTS__
  21.     #include <CodeFragments.h>
  22. #endif
  23.  
  24. #ifndef __EVENTS__
  25.     #include <Events.h>
  26. #endif
  27.  
  28. #ifndef __THREADS__
  29.     #include <Threads.h>
  30. #endif
  31.  
  32. #ifndef __MACERRORS__
  33.     #include <MacErrors.h>
  34. #endif
  35.  
  36.  
  37.  
  38.  
  39. #if PRAGMA_ONCE
  40. #pragma once
  41. #endif
  42.  
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46.  
  47. #if PRAGMA_IMPORT
  48. #pragma import on
  49. #endif
  50.  
  51. #if PRAGMA_STRUCT_ALIGN
  52.     #pragma options align=mac68k
  53. #elif PRAGMA_STRUCT_PACKPUSH
  54.     #pragma pack(push, 2)
  55. #elif PRAGMA_STRUCT_PACK
  56.     #pragma pack(2)
  57. #endif
  58.  
  59. enum {
  60.     kNSLMinSystemVersion        = 0x0900,                        /* equivalent to 9.0*/
  61.     kNSLMinOTVersion            = 0x0130                        /* equivalent to 1.3*/
  62. };
  63.  
  64. enum {
  65.     kNSLDefaultListSize            = 256                            /* default list size for service and protocol lists*/
  66. };
  67.  
  68. enum {
  69.     kNSLURLDelimiter            = ','                            /* delimits URL's within memory buffers*/
  70. };
  71.  
  72.  
  73. #define    kNSLErrorNoErr                {noErr, kNSLNoContext}        /* an initializer for the NSLError struct */
  74.  
  75. enum {
  76.     kNSLNoContext                = 0                                /* the default context for NSLError structs*/
  77. };
  78.  
  79.  
  80. struct NSLError {
  81.     OSStatus                         theErr;
  82.     UInt32                             theContext;
  83. };
  84. typedef struct NSLError                    NSLError;
  85. typedef NSLError *                        NSLErrorPtr;
  86. enum {
  87.                                                                 /* Constants to use with NSLPrepareRequest*/
  88.                                                                 /* kNSLDuplicateSearchInProgress is not strictly an error.  The client is free to ignore*/
  89.                                                                 /* this result, and nothing bad will happen if it does.  It is*/
  90.                                                                 /* informational only.*/
  91.     kNSLDuplicateSearchInProgress = 100,
  92.     kNSLUserCanceled            = userCanceledErr,                /* User hit cancel from the NSLStandardGetURL dialog */
  93.                                                                 /* Invalid enumeratorRef    */
  94.     kNSLInvalidEnumeratorRef    = 0                                /* this is not an error; it is the equiv to a NULL ptr*/
  95. };
  96.  
  97.  
  98. typedef UInt16 NSLSearchState;
  99. enum {
  100.                                                                 /* State codes for notifiers.*/
  101.     kNSLSearchStateBufferFull    = 1,
  102.     kNSLSearchStateOnGoing        = 2,
  103.     kNSLSearchStateComplete        = 3,
  104.     kNSLSearchStateStalled        = 4,
  105.     kNSLWaitingForContinue        = 5
  106. };
  107.  
  108.  
  109. typedef UInt32 NSLEventCode;
  110. enum {
  111.                                                                 /* Event codes*/
  112.     kNSLServicesLookupDataEvent    = 6,
  113.     kNSLNeighborhoodLookupDataEvent = 7,
  114.     kNSLNewDataEvent            = 8,
  115.     kNSLContinueLookupEvent        = 9
  116. };
  117.  
  118.  
  119.  
  120. typedef UInt32                             NSLClientRef;
  121. typedef UInt32                             NSLRequestRef;
  122. typedef UInt32                             NSLOneBasedIndex;
  123. typedef char *                            NSLPath;
  124. typedef char *                            NSLServiceType;
  125. typedef Handle                             NSLServicesList;
  126. typedef unsigned char *                    NSLNeighborhood;
  127. /*
  128.    cstring which is a comma delimited list of protocols which can be used to
  129.    create a NSLProtocolList internally
  130. */
  131.  
  132. typedef UInt32 NSLDialogOptionFlags;
  133. enum {
  134.     kNSLDefaultNSLDlogOptions    = 0x00000000,                    /* use defaults for all the options */
  135.     kNSLNoURLTEField            = 0x00000001                    /* don't show url text field for manual entry */
  136. };
  137.  
  138.  
  139.  
  140. struct NSLDialogOptions {
  141.     UInt16                             version;
  142.     NSLDialogOptionFlags             dialogOptionFlags;            /* option flags for affecting the dialog's behavior */
  143.     Str255                             windowTitle;
  144.     Str255                             actionButtonLabel;            /* label of the default button (or null string for default) */
  145.     Str255                             cancelButtonLabel;            /* label of the cancel button (or null string for default) */
  146.     Str255                             message;                    /* custom message prompt (or null string for default) */
  147. };
  148. typedef struct NSLDialogOptions            NSLDialogOptions;
  149.  
  150. /* the async information block for client<->manager interaction*/
  151.  
  152. struct NSLClientAsyncInfo {
  153.     void *                            clientContextPtr;            /* set by the client for its own use*/
  154.     void *                            mgrContextPtr;                /* set by NSL mgr; ptr to request object ptr*/
  155.     char *                            resultBuffer;
  156.     long                             bufferLen;
  157.     long                             maxBufferSize;
  158.     UInt32                             startTime;                    /* when the search starts, to use with maxSearchTime to determine time-out condition*/
  159.     UInt32                             intStartTime;                /* used with alertInterval*/
  160.     UInt32                             maxSearchTime;                /* total time for search, in ticks (0 == no time limit)*/
  161.     UInt32                             alertInterval;                /* call client's notifier or return, every this many ticks ( 0 == don't use this param)*/
  162.     UInt32                             totalItems;                    /* total number of tuples currently in buffer*/
  163.     UInt32                             alertThreshold;                /* call client's notifier or return, every this many items found ( 0 == don't use this param)*/
  164.     NSLSearchState                     searchState;
  165.     NSLError                         searchResult;
  166.     NSLEventCode                     searchDataType;                /* this is a data type code which allows the client's asyncNotifier to properly*/
  167.                                                                 /* handle the data in resultBuffer.*/
  168. };
  169. typedef struct NSLClientAsyncInfo        NSLClientAsyncInfo;
  170. typedef NSLClientAsyncInfo *            NSLClientAsyncInfoPtr;
  171.  
  172. /* the async information block plugin<->manager interaction*/
  173.  
  174. struct NSLPluginAsyncInfo {
  175.     void *                            mgrContextPtr;                /* set by NSL mgr; ptr to request object ptr*/
  176.     void *                            pluginContextPtr;            /* set/used by individual plugins*/
  177.     void *                            pluginPtr;                    /* ptr to the plugin object waiting for continue lookup call*/
  178.     char *                            resultBuffer;                /* set by plugin to point at data*/
  179.     long                             bufferLen;
  180.     long                             maxBufferSize;
  181.     UInt32                             maxSearchTime;                /* total time for search, in ticks (0 == no time limit)*/
  182.     UInt32                             reserved1;
  183.     UInt32                             reserved2;
  184.     UInt32                             reserved3;
  185.     NSLClientRef                     clientRef;
  186.     NSLRequestRef                     requestRef;
  187.     NSLSearchState                     searchState;
  188.     OSStatus                         searchResult;
  189. };
  190. typedef struct NSLPluginAsyncInfo        NSLPluginAsyncInfo;
  191. typedef NSLPluginAsyncInfo *            NSLPluginAsyncInfoPtr;
  192.  
  193. /* the mgr asynchronous notifier routine.*/
  194. typedef CALLBACK_API( void , NSLMgrNotifyProcPtr )(NSLPluginAsyncInfo *thePluginAsyncInfo);
  195.  
  196. /* the client asynchronous notifier routine.*/
  197. typedef CALLBACK_API( void , NSLClientNotifyProcPtr )(NSLClientAsyncInfo *theClientAsyncInfo);
  198. typedef STACK_UPP_TYPE(NSLMgrNotifyProcPtr)                     NSLMgrNotifyUPP;
  199. typedef STACK_UPP_TYPE(NSLClientNotifyProcPtr)                     NSLClientNotifyUPP;
  200. #if OPAQUE_UPP_TYPES
  201.     EXTERN_API(NSLMgrNotifyUPP)
  202.     NewNSLMgrNotifyUPP               (NSLMgrNotifyProcPtr        userRoutine);
  203.  
  204.     EXTERN_API(NSLClientNotifyUPP)
  205.     NewNSLClientNotifyUPP           (NSLClientNotifyProcPtr    userRoutine);
  206.  
  207.     EXTERN_API(void)
  208.     DisposeNSLMgrNotifyUPP           (NSLMgrNotifyUPP            userUPP);
  209.  
  210.     EXTERN_API(void)
  211.     DisposeNSLClientNotifyUPP       (NSLClientNotifyUPP        userUPP);
  212.  
  213.     EXTERN_API(void)
  214.     InvokeNSLMgrNotifyUPP           (NSLPluginAsyncInfo *    thePluginAsyncInfo,
  215.                                     NSLMgrNotifyUPP            userUPP);
  216.  
  217.     EXTERN_API(void)
  218.     InvokeNSLClientNotifyUPP       (NSLClientAsyncInfo *    theClientAsyncInfo,
  219.                                     NSLClientNotifyUPP        userUPP);
  220.  
  221. #else
  222.     enum { uppNSLMgrNotifyProcInfo = 0x000000C0 };                     /* pascal no_return_value Func(4_bytes) */
  223.     enum { uppNSLClientNotifyProcInfo = 0x000000C0 };                 /* pascal no_return_value Func(4_bytes) */
  224.     #define NewNSLMgrNotifyUPP(userRoutine)                         (NSLMgrNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLMgrNotifyProcInfo, GetCurrentArchitecture())
  225.     #define NewNSLClientNotifyUPP(userRoutine)                         (NSLClientNotifyUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLClientNotifyProcInfo, GetCurrentArchitecture())
  226.     #define DisposeNSLMgrNotifyUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  227.     #define DisposeNSLClientNotifyUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  228.     #define InvokeNSLMgrNotifyUPP(thePluginAsyncInfo, userUPP)         CALL_ONE_PARAMETER_UPP((userUPP), uppNSLMgrNotifyProcInfo, (thePluginAsyncInfo))
  229.     #define InvokeNSLClientNotifyUPP(theClientAsyncInfo, userUPP)     CALL_ONE_PARAMETER_UPP((userUPP), uppNSLClientNotifyProcInfo, (theClientAsyncInfo))
  230. #endif
  231. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  232. #define NewNSLMgrNotifyProc(userRoutine)                         NewNSLMgrNotifyUPP(userRoutine)
  233. #define NewNSLClientNotifyProc(userRoutine)                     NewNSLClientNotifyUPP(userRoutine)
  234. #define CallNSLMgrNotifyProc(userRoutine, thePluginAsyncInfo)    InvokeNSLMgrNotifyUPP(thePluginAsyncInfo, userRoutine)
  235. #define CallNSLClientNotifyProc(userRoutine, theClientAsyncInfo) InvokeNSLClientNotifyUPP(theClientAsyncInfo, userRoutine)
  236.  
  237. /*
  238.    this struct is a format for dealing with our internal data representation.  Typed data will be contiguous chunk of
  239.    memory, with the first 4 bytes being a data "descriptor".
  240. */
  241.  
  242. struct NSLTypedData {
  243.     unsigned long                     dataType;
  244.     unsigned long                     lengthOfData;
  245. /*    void*                            theData; */
  246.  
  247. };
  248. typedef struct NSLTypedData                NSLTypedData;
  249. typedef NSLTypedData *                    NSLTypedDataPtr;
  250.  
  251. #define kNSLDataType                'NSL_'
  252. /*
  253.    This is just a header at the beginning of a handle that stores our list of service types.
  254.    Each service type is a pascal string, so each service type starts after the end of the
  255.    previous one.
  256. */
  257.  
  258. struct NSLServicesListHeader {
  259.     unsigned long                     numServices;
  260.     unsigned long                     logicalLen;                    /* length of all usable data in handle*/
  261. /*    Ptr                                firstService; */
  262.  
  263. };
  264. typedef struct NSLServicesListHeader    NSLServicesListHeader;
  265. typedef NSLServicesListHeader *            NSLServicesListHeaderPtr;
  266.  
  267. /* some defs for common protocols*/
  268.  
  269. #define    kSLPProtocolType            "SLP"
  270. #define    kDNSProtocolType            "DNS"
  271. #define    kLDAPProtocolType            "LDAP"
  272. #define kNBPProtocolType            "NBP"
  273.  
  274. /*
  275.    general information from a plug-in.  Includes supported protocols, data types and services,
  276.    as well as an info/comment string describing the function of the plug-in in human-readable
  277.    form.  The offsets point to the beginning of each list of data returned, and the protocol
  278.    data offset is the startOfData member of the struct
  279. */
  280.  
  281. struct NSLPluginData {
  282.     long                             reserved1;
  283.     long                             reserved2;
  284.     long                             reserved3;
  285.     Boolean                         supportsRegistration;
  286.     Boolean                         isPurgeable;
  287.     UInt16                             totalLen;                    /* length of everything, including header*/
  288.     UInt16                             dataTypeOffset;
  289.     UInt16                             serviceListOffset;
  290.     UInt16                             protocolListOffset;
  291.     UInt16                             commentStringOffset;
  292. /*    char*                            startOfData; */
  293.                                                                 /* protocol data is first on the list*/
  294. };
  295. typedef struct NSLPluginData            NSLPluginData;
  296. typedef NSLPluginData *                    NSLPluginDataPtr;
  297.  
  298. /*
  299.   -----------------------------------------------------------------------------
  300.       Finding out if the library is present and getting its version
  301.   -----------------------------------------------------------------------------
  302. */
  303.  
  304. EXTERN_API( UInt32 )
  305. NSLLibraryVersion                (void);
  306.  
  307.  
  308.  
  309.     #ifdef __cplusplus
  310.         inline pascal Boolean NSLLibraryPresent() { return NSLLibraryVersion != (void*)kUnresolvedCFragSymbolAddress; }
  311.     #else
  312.         #define NSLLibraryPresent()        ((NSLLibraryVersion != (void*)kUnresolvedCFragSymbolAddress))
  313.     #endif
  314.     
  315. typedef CALLBACK_API( Boolean , NSLURLFilterProcPtr )(char *url, Str255 displayString)/*  optional filter function */;
  316. /* you can provide for calls to NSLStandardGetURL*/
  317. typedef CALLBACK_API( void , NSLEventProcPtr )(EventRecord *newEvent, void *userContext)/*  optional callback routine for getting Events while the dialog is up */;
  318. typedef STACK_UPP_TYPE(NSLURLFilterProcPtr)                     NSLURLFilterUPP;
  319. typedef STACK_UPP_TYPE(NSLEventProcPtr)                         NSLEventUPP;
  320. #if OPAQUE_UPP_TYPES
  321.     EXTERN_API(NSLURLFilterUPP)
  322.     NewNSLURLFilterUPP               (NSLURLFilterProcPtr        userRoutine);
  323.  
  324.     EXTERN_API(NSLEventUPP)
  325.     NewNSLEventUPP                   (NSLEventProcPtr            userRoutine);
  326.  
  327.     EXTERN_API(void)
  328.     DisposeNSLURLFilterUPP           (NSLURLFilterUPP            userUPP);
  329.  
  330.     EXTERN_API(void)
  331.     DisposeNSLEventUPP               (NSLEventUPP                userUPP);
  332.  
  333.     EXTERN_API(Boolean)
  334.     InvokeNSLURLFilterUPP           (char *                    url,
  335.                                     Str255                    displayString,
  336.                                     NSLURLFilterUPP            userUPP);
  337.  
  338.     EXTERN_API(void)
  339.     InvokeNSLEventUPP               (EventRecord *            newEvent,
  340.                                     void *                    userContext,
  341.                                     NSLEventUPP                userUPP);
  342.  
  343. #else
  344.     enum { uppNSLURLFilterProcInfo = 0x000003D0 };                     /* pascal 1_byte Func(4_bytes, 4_bytes) */
  345.     enum { uppNSLEventProcInfo = 0x000003C0 };                         /* pascal no_return_value Func(4_bytes, 4_bytes) */
  346.     #define NewNSLURLFilterUPP(userRoutine)                         (NSLURLFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLURLFilterProcInfo, GetCurrentArchitecture())
  347.     #define NewNSLEventUPP(userRoutine)                             (NSLEventUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppNSLEventProcInfo, GetCurrentArchitecture())
  348.     #define DisposeNSLURLFilterUPP(userUPP)                         DisposeRoutineDescriptor(userUPP)
  349.     #define DisposeNSLEventUPP(userUPP)                             DisposeRoutineDescriptor(userUPP)
  350.     #define InvokeNSLURLFilterUPP(url, displayString, userUPP)         (Boolean)CALL_TWO_PARAMETER_UPP((userUPP), uppNSLURLFilterProcInfo, (url), (displayString))
  351.     #define InvokeNSLEventUPP(newEvent, userContext, userUPP)         CALL_TWO_PARAMETER_UPP((userUPP), uppNSLEventProcInfo, (newEvent), (userContext))
  352. #endif
  353. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  354. #define NewNSLURLFilterProc(userRoutine)                         NewNSLURLFilterUPP(userRoutine)
  355. #define NewNSLEventProc(userRoutine)                             NewNSLEventUPP(userRoutine)
  356. #define CallNSLURLFilterProc(userRoutine, url, displayString)    InvokeNSLURLFilterUPP(url, displayString, userRoutine)
  357. #define CallNSLEventProc(userRoutine, newEvent, userContext)    InvokeNSLEventUPP(newEvent, userContext, userRoutine)
  358.  
  359. /*
  360.   -----------------------------------------------------------------------------
  361.       High level API calls: the following two calls are ALL an application needs
  362.        to register/deregister its service.
  363.     If you use these, you don't need to make any of the other calls to NSLAPI 
  364.       (including NSLOpenNavigationAPI) 
  365.   -----------------------------------------------------------------------------
  366. */
  367.  
  368. /* <--- error code from registration */
  369. /* ---> urlToRegister is a null terminated url that has only legal characters defined for URLs.  Use HexEncodeText to encode*/
  370. /*            portions of the url that have illegal characters */
  371. /* ---> neighborhoodToRegisterIn is an optional parameter for explicitly defining a neighborhood to register in.
  372.             If parameter is NULL, then the plugins will determine where to register the service */
  373. EXTERN_API( NSLError )
  374. NSLStandardRegisterURL            (NSLPath                 urlToRegister,
  375.                                  NSLNeighborhood         neighborhoodToRegisterIn) /* can be NULL */;
  376.  
  377. /* <--- error code from registration */
  378. /* ---> urlToRegister is a null terminated url that has only legal characters defined for URLs.  Use HexEncodeText to encode*/
  379. /*            portions of the url that have illegal characters */
  380. /* ---> neighborhoodToDeregisterIn is an optional parameter for explicitly defining a neighborhood to register in.
  381.             If parameter is NULL, then the plugins will determine where to register the service */
  382. EXTERN_API( NSLError )
  383. NSLStandardDeregisterURL        (NSLPath                 urlToDeregister,
  384.                                  NSLNeighborhood         neighborhoodToDeregisterIn) /* can be NULL */;
  385.  
  386. /* <--- function returns OSStatus of the operation.  noErr will be returned if valid, kNSLUserCanceled will be returned if the user cancels */
  387. /* ---> dialogOptions */
  388. /* ---> eventProc */
  389. /* ---> eventProcContextPtr */
  390. /* ---> filterProc */
  391. /* ---> serviceTypeList */
  392. /* <--- userSelectedURL */
  393. /* NSLDialogOptions* dialogOptions */
  394. /*
  395.    dialogOptions is a user defined structure defining the look, feel and operation of NSLStandardGetURL dialog
  396.    default behavior can be achieved by passing in a pointer to a structure that has been filled out by a previous
  397.    call to NSLGetDefaultDialogOptions or by passing in NULL.
  398. */
  399. /* NSLEventUPP eventProc */
  400. /*
  401.    the eventProc is a callback NSLURLFilterUPP that will
  402.    get called with Events that the dialog doesn't handle.  If you pass in nil,
  403.    you won't get update events while the NSLStandardGetURL dialog is open.
  404. */
  405. /* void* eventProcContextPtr */
  406. /* you can provide a pointer to some contextual data that you want to have sent to your eventProc filter*/
  407. /* NSLURLFilterProcPtr filterProc */
  408. /*
  409.    the filter param is a callback NSLURLFilterUPP that
  410.    will get called (if not nil) for each url that is going to be displayed in
  411.    the dialog's result list.  A result of false will not include the url for the
  412.    user to select from.  You also have the option of handling the way the url looks
  413.    in the dialog listing by copying the preferred name into the displayString
  414.    parameter.  (If left alone, NSLStandardGetURL dialog will strip the service type
  415.    portion off the url).
  416. */
  417. /* char* serviceTypeList */
  418. /*
  419.    the serviceTypeList parameter is a null terminated string that will 
  420.    directly affect the contents of the services popup in the dialog.
  421.    The structure of this string is a set of tuples as follows:
  422.    Name of ServiceType as to be represented in the popup followed by
  423.    a comma delimted list of service descriptors (ie http,https) that will
  424.    used in the search of that type.  Each comma delimited tuple is delimited
  425.    by semi-colons.
  426. */
  427. /*
  428.    For example:
  429.    If you want to search for services of type http (web), https (secure web),
  430.    and ftp, you could pass in the string "Web Servers,http,https;FTP Servers,ftp".
  431.    This would result in a popup list with two items ("Web Servers" and "FTP Servers")
  432.    and searches performed on them will provide results of type http and https for the
  433.    first, and ftp for the second.
  434. */
  435.  
  436. /*
  437.    Results list Icons:
  438.    NSLStandardGetURL provides icons in its listings for the following types:
  439.    "http", "https", "ftp", "afp", "lpr", "LaserWriter", "AFPServer"
  440.    any other types will get a generic icon.  However, you can provide icons
  441.    if you wish by including an '#ics8' resource id at the end of your comma
  442.    delimited list.  The dialog will then use that icon if found in its results
  443.    list.  This icon will be used for all types in a tuple.
  444.    For example:
  445.    The param "Web Servers,http,https;Telnet Servers,telnet;NFS Servers,nfs,129"
  446.    would result in lists of http and https services to be shown with their default
  447.    icons, telnet servers would be shown with the default misc. icon and nfs
  448.    servers would be shown with your icon at resource id 129.
  449. */
  450.  
  451. /* char** url */
  452. /*
  453.    pass in the address of a char* and it will point to the resulting url.  If the user
  454.    cancels (the function returns false), the pointer will be set to nil.  If the function
  455.    returns true (user selected a url), then you must call NSLFreeURL on the pointer when
  456.    you are done with it.
  457. */
  458. /*
  459.    Call this to have the user select a url based service from a dialog.
  460.    Function takes on input an optional filter proc, a serviceTypeList, and an address to a Ptr.
  461.    Function sets the value of the Ptr to a newly created c-style null terminated string
  462.    containing the user's choice of URL.
  463. */
  464.  
  465. EXTERN_API( OSStatus )
  466. NSLStandardGetURL                (NSLDialogOptions *        dialogOptions, /* can be NULL */
  467.                                  NSLEventUPP             eventProc, /* can be NULL */
  468.                                  void *                    eventProcContextPtr, /* can be NULL */
  469.                                  NSLURLFilterUPP         filterProc, /* can be NULL */
  470.                                  char *                    serviceTypeList,
  471.                                  char **                userSelectedURL);
  472.  
  473. /*-----------------------------------------------------------------------------*/
  474.  
  475. EXTERN_API( OSStatus )
  476. NSLHexEncodeText                (const char *            rawText,
  477.                                  UInt16                 rawTextLen,
  478.                                  char *                    newTextBuffer,
  479.                                  UInt16 *                newTextBufferLen,
  480.                                  Boolean *                textChanged);
  481.  
  482. EXTERN_API( OSStatus )
  483. NSLHexDecodeText                (const char *            encodedText,
  484.                                  UInt16                 encodedTextLen,
  485.                                  char *                    decodedTextBuffer,
  486.                                  UInt16 *                decodedTextBufferLen,
  487.                                  Boolean *                textChanged);
  488.  
  489. EXTERN_API( OSStatus )
  490. NSLGetDefaultDialogOptions        (NSLDialogOptions *        dialogOptions);
  491.  
  492. /* <--- function returns null (useful for setting variable at same time as freeing it */
  493. /* ---> url is memory created by a call to NSLStandardGetURL */
  494. EXTERN_API( char *)
  495. NSLFreeURL                        (char *                    url);
  496.  
  497. /*
  498.   -----------------------------------------------------------------------------
  499.       Basic API Utility calls: sufficient to create, and parse data structures
  500.   -----------------------------------------------------------------------------
  501. */
  502.  
  503. EXTERN_API( NSLServicesList )
  504. NSLMakeNewServicesList            (const char *            initialServiceList);
  505.  
  506. EXTERN_API( NSLError )
  507. NSLAddServiceToServicesList        (NSLServicesList         serviceList,
  508.                                  NSLServiceType         serviceType);
  509.  
  510. EXTERN_API( void )
  511. NSLDisposeServicesList            (NSLServicesList         theList);
  512.  
  513. /*
  514.     The name reflects the name of the Neighborhood, i.e. "apple.com." or "AppleTalk Zone One".
  515.     The protocolList is a comma delimited list of protocols that the Neighborhood might exist in.
  516.     If the user passes in NULL, then all protocols will be queried.  The result must be disposed
  517.     of by the user by calling NSLFreeNeighborhood.
  518. */
  519. EXTERN_API( NSLNeighborhood )
  520. NSLMakeNewNeighborhood            (const char *            name,
  521.                                  const char *            protocolList) /* can be NULL */;
  522.  
  523. /* creates an exact copy of an existing neighborhood */
  524. EXTERN_API( NSLNeighborhood )
  525. NSLCopyNeighborhood                (NSLNeighborhood         neighborhood);
  526.  
  527. EXTERN_API( NSLNeighborhood )
  528. NSLFreeNeighborhood                (NSLNeighborhood         neighborhood);
  529.  
  530. EXTERN_API( void )
  531. NSLGetNameFromNeighborhood        (NSLNeighborhood         neighborhood,
  532.                                  char **                name,
  533.                                  long *                    length);
  534.  
  535. /*
  536.    create a block of formatted data, pointed to by newDataPtr.  This will be used
  537.    in calls (typically request-related calls) for plug-ins that handle the NSL data type.
  538. */
  539. EXTERN_API( OSStatus )
  540. NSLMakeServicesRequestPB        (NSLServicesList         serviceList,
  541.                                  NSLTypedDataPtr *        newDataPtr);
  542.  
  543. /* releases any storage created with MakeXXXPB calls, associated with TypedData.*/
  544. EXTERN_API( NSLTypedDataPtr )
  545. NSLFreeTypedDataPtr                (NSLTypedDataPtr         nslTypeData);
  546.  
  547. /*
  548.    utility function that returns whether a url was found, a pointer to the beginning
  549.    of the url, and the length of the URL.
  550. */
  551. EXTERN_API( Boolean )
  552. NSLGetNextUrl                    (NSLClientAsyncInfoPtr     infoPtr,
  553.                                  char **                urlPtr,
  554.                                  long *                    urlLength);
  555.  
  556. /*
  557.    utility function that returns whether a Neighborhood was found, a pointer to the beginning
  558.    of the Neighborhood, and the length of the Neighborhood.
  559. */
  560. EXTERN_API( Boolean )
  561. NSLGetNextNeighborhood            (NSLClientAsyncInfoPtr     infoPtr,
  562.                                  NSLNeighborhood *        neighborhood,
  563.                                  long *                    neighborhoodLength);
  564.  
  565.  
  566. /*
  567.    NSLErrorToString:    convert a numeric error code to its string equivalent.  Caller must
  568.                            have allocated sufficient space to store both strings.  (Max 255 chars each)
  569.                                   
  570.                           The errorString parameter will return a textual explanation of what is wrong,
  571.                           while the solutionString returns a possible solution to get around the problem
  572. */
  573.  
  574. EXTERN_API( OSStatus )
  575. NSLErrorToString                (NSLError                 theErr,
  576.                                  char *                    errorString,
  577.                                  char *                    solutionString);
  578.  
  579.  
  580. /*
  581.   -----------------------------------------------------------------------------
  582.       Basic API calls: sufficient to create simple requests, and receive answers
  583.   -----------------------------------------------------------------------------
  584. */
  585.  
  586. EXTERN_API( OSStatus )
  587. NSLOpenNavigationAPI            (NSLClientRef *            newRef);
  588.  
  589. EXTERN_API( void )
  590. NSLCloseNavigationAPI            (NSLClientRef             theClient);
  591.  
  592. /*
  593.       NSLPrepareRequest:    creates an NSLRequestRef, sets up some internal data
  594.       notifier is an NSLClientNotifyUPP that will be called when data is available, when the lookup has
  595.     completed, or if an error occurs.  When the notifier is called, the cookie will be the NSLRequestRef.
  596.     If notifier is NULL, then the NSLManager will assume that the request is made synchronously.  This
  597.     should only be used while in a separate thread, so that the client app can still process events, etc.
  598.       
  599.       contextPtr is a void* which is passed as the contextPtr argument when the notifier is called.  
  600.       
  601.       upon exit:
  602.       1) ref will contain a pointer to a NSLRequestRef which must be passed to all other functions
  603.       which require a NSLRequestRef.
  604.       2) infoPtr will point to a newly created ClientAsycnInfoPtr which will be disposed by the manager when the search is completed
  605.       NOTE: Only one search can be running at a time per clientRef.
  606. */
  607.  
  608. EXTERN_API( NSLError )
  609. NSLPrepareRequest                (NSLClientNotifyUPP     notifier,
  610.                                  void *                    contextPtr,
  611.                                  NSLClientRef             theClient,
  612.                                  NSLRequestRef *        ref,
  613.                                  char *                    bufPtr,
  614.                                  unsigned long             bufLen,
  615.                                  NSLClientAsyncInfoPtr * infoPtr);
  616.  
  617.  
  618. /*
  619.    NSLStartNeighborhoodLookup: looking for neighborhoods associated with or neighboring a particular neighborhood
  620.       Passing in NULL for neighborhood will generate a list of a default neighborhood(s)
  621.    
  622. */
  623.  
  624. EXTERN_API( NSLError )
  625. NSLStartNeighborhoodLookup        (NSLRequestRef             ref,
  626.                                  NSLNeighborhood         neighborhood,
  627.                                  NSLClientAsyncInfo *    asyncInfo);
  628.  
  629. /*
  630.    NSLStartServicesLookup: starts looking for entities if the specified type in the specified neighborhood
  631.    
  632. */
  633.  
  634. EXTERN_API( NSLError )
  635. NSLStartServicesLookup            (NSLRequestRef             ref,
  636.                                  NSLNeighborhood         neighborhood,
  637.                                  NSLTypedDataPtr         requestData,
  638.                                  NSLClientAsyncInfo *    asyncInfo);
  639.  
  640.  
  641. /* NSLContinueLookup:  continues a paused/outstanding lookup*/
  642.  
  643. EXTERN_API( NSLError )
  644. NSLContinueLookup                (NSLClientAsyncInfo *    asyncInfo);
  645.  
  646.  
  647. /* NSLCancelRequest: cancels an ongoing search*/
  648.  
  649. EXTERN_API( NSLError )
  650. NSLCancelRequest                (NSLRequestRef             ref);
  651.  
  652. /*
  653.    NSLDeleteRequest: deletes info associated with this ref.  The ClientAsyncInfoPtr will no longer be valid
  654.       This must be called when the client is no longer using this requestRef.
  655. */
  656.  
  657. EXTERN_API( NSLError )
  658. NSLDeleteRequest                (NSLRequestRef             ref);
  659.  
  660.  
  661. /*
  662.   -----------------------------------------------------------------------------
  663.    Utility API calls: use these accessors to manipulate NSL's typed data
  664.   -----------------------------------------------------------------------------
  665. */
  666.  
  667. /* NSLParseServicesRequestPB provides the inverse of NSLMakeRequestPB, filling out the offsets found within newDataPtr*/
  668. /* <--- returns an OSStatus if any errors occur parsing the data */
  669. /* <--- newDataPtr is the construct passed to the plugin */
  670. /* --->    serviceListPtr is the address of a pointer which will be set to point at the portion of the newDataPtr that holds the serviceList to be searched */
  671. /* ---> serviceListLen is the length of the serviceListPtr data pointed to by serviceListPtr */
  672. EXTERN_API( OSStatus )
  673. NSLParseServicesRequestPB        (NSLTypedDataPtr         newDataPtr,
  674.                                  char **                serviceListPtr,
  675.                                  UInt16 *                serviceListLen);
  676.  
  677.  
  678. /* NSLParseServiceRegistrationPB provides for breaking apart a registration request from a client to a plugin*/
  679. /* <--- returns an OSStatus if any errors occur parsing the data */
  680. /* <--- newDataPtr is the construct passed to the plugin */
  681. /* ---> neighborhoodPtr gets set to point at the portion of the newDataPtr that contains the neighborhood */
  682. /* ---> neighborhoodLen is the length of the neighborhood pointed to by neighborhoodPtr */
  683. /* --->    urlPtr is the address of a pointer which will be set to point at the portion of the newDataPtr that holds the url to be registered */
  684. /* ---> urlLen is the length of the url data pointed to by urlPtr */
  685. EXTERN_API( OSStatus )
  686. NSLParseServiceRegistrationPB    (NSLTypedDataPtr         newDataPtr,
  687.                                  NSLNeighborhood *        neighborhoodPtr,
  688.                                  UInt16 *                neighborhoodLen,
  689.                                  char **                urlPtr,
  690.                                  UInt16 *                urlLen);
  691.  
  692. /*
  693.       NSLGetErrorStringsFromResource makes a basic assumption!
  694.       errorString and solutionString both point to valid memory of at least 256 bytes!
  695. */
  696. /* <--- returns an OSStatus if any errors occur */
  697. /* ---> theErr is an OSStatus to be matched against a resource list of errors */
  698. /* ---> fileSpecPtr is a FSSpecPtr to the resource containing the list of errors */
  699. /* ---> errorResID is the resourceID of the NSLI resource of the list of errors */
  700. /* <--> errorString is a pointer to valid memory of at least 256 bytes which will be filled out by the error portion of the error string */
  701. /* <--> solutionString is a pointer to valid memory of at least 256 bytes which will be filled out by the solution portion of the error string */
  702. EXTERN_API( OSStatus )
  703. NSLGetErrorStringsFromResource    (OSStatus                 theErr,
  704.                                  const FSSpec *            fileSpecPtr,
  705.                                  SInt16                 errorResID,
  706.                                  char *                    errorString,
  707.                                  char *                    solutionString);
  708.  
  709. /* <---    Returns true if given service is in the given service list */
  710. /* ---> serviceList is a valid NSLServicesList containing information about services to be searched */
  711. /* ---> svcToFind is an NSLServiceType of a particular service to check if it is in the serviceList */
  712. EXTERN_API( Boolean )
  713. NSLServiceIsInServiceList        (NSLServicesList         serviceList,
  714.                                  NSLServiceType         svcToFind);
  715.  
  716. /* <--- returns an OSStatus if any errors occur parsing the data */
  717. /* --->    svcString is the address of a pointer which will be set to point at the portion of theURL that holds the serviceType of theURL */
  718. /* ---> svcLen is the length of the serviceType pointed to by svcString */
  719. EXTERN_API( OSStatus )
  720. NSLGetServiceFromURL            (char *                    theURL,
  721.                                  char **                svcString,
  722.                                  UInt16 *                svcLen);
  723.  
  724. /* <--- returns the length of a Neighborhood data structure */
  725. /* ---> neighborhood is a valid NSLNeighborhood */
  726. EXTERN_API( long )
  727. NSLGetNeighborhoodLength        (NSLNeighborhood         neighborhood);
  728.  
  729. /*
  730.   -------------------------------------------------------------------------------------
  731.    Utility API calls: use these routines to separate plugin threads from client threads
  732.   -------------------------------------------------------------------------------------
  733. */
  734.  
  735. /* this routine works the same as the Thread manager's routine NewThread, except */
  736. /* that the thread is added to the NSL manager's thread list. */
  737. EXTERN_API( OSErr )
  738. NSLNewThread                    (ThreadStyle             threadStyle,
  739.                                  ThreadEntryProcPtr     threadEntry,
  740.                                  void *                    threadParam,
  741.                                  Size                     stackSize,
  742.                                  ThreadOptions             options,
  743.                                  void **                threadResult,
  744.                                  ThreadID *                threadMade);
  745.  
  746. /* this routine works the same as the Thread manager's routine DisposeThread, except */
  747. /* that the thread is removed from the NSL manager's thread list. */
  748. EXTERN_API( OSErr )
  749. NSLDisposeThread                (ThreadID                 threadToDump,
  750.                                  void *                    threadResult,
  751.                                  Boolean                 recycleThread);
  752.  
  753. #if OLDROUTINENAMES
  754.  
  755. typedef NSLClientAsyncInfo                 ClientAsyncInfo;
  756. typedef NSLPluginAsyncInfo                 PluginAsyncInfo;
  757. typedef NSLTypedData                     TypedData;
  758. typedef NSLPluginData                     PluginData;
  759. typedef NSLClientAsyncInfoPtr             ClientAsyncInfoPtr;
  760. typedef NSLPluginAsyncInfoPtr             PluginAsyncInfoPtr;
  761. typedef NSLTypedDataPtr                 TypedDataPtr;
  762. typedef NSLPluginDataPtr                 PluginDataPtr;
  763.  
  764. #endif  /* OLDROUTINENAMES */
  765.  
  766.  
  767. #if PRAGMA_STRUCT_ALIGN
  768.     #pragma options align=reset
  769. #elif PRAGMA_STRUCT_PACKPUSH
  770.     #pragma pack(pop)
  771. #elif PRAGMA_STRUCT_PACK
  772.     #pragma pack()
  773. #endif
  774.  
  775. #ifdef PRAGMA_IMPORT_OFF
  776. #pragma import off
  777. #elif PRAGMA_IMPORT
  778. #pragma import reset
  779. #endif
  780.  
  781. #ifdef __cplusplus
  782. }
  783. #endif
  784.  
  785. #endif /* __NSL__ */
  786.  
  787.